package com.mchsdk.paysdk.bean;

import com.mchsdk.open.MCApiFactory;
import com.mchsdk.paysdk.common.Constant;
import com.mchsdk.paysdk.entity.ChannelAndGameinfo;
import com.mchsdk.paysdk.utils.PreSharedManager;
import com.mchsdk.paysdk.utils.ToastUtil;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

public class PersonalCenterModel {

	public ChannelAndGameinfo channelAndGame = null;

	private boolean isUpdatePwd;

	private static PersonalCenterModel instance;

	public static PersonalCenterModel getInstance() {
		if (null == instance) {
			instance = new PersonalCenterModel();
		}
		return instance;
	}

	public PersonalCenterModel() {
		channelAndGame = new ChannelAndGameinfo();
		isUpdatePwd = false;
	}

	public String getAccount() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getAccount();
	}
	public String getIs_uc() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getIs_uc();
	}
	public String getReal_name() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getReal_name();
	}
	public String getIdcard() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getIdcard();
	}
	public String getGameName() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getGameName();
	}

	public String getPhone() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getPhoneNumber();
	}
	
	public String getUserPtb() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getPlatformMoney()+"";
	}
	
	public String getBindPtb() {
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getBindPtbMoney()+"";
	}

	public void setPhone(String phone) {
		if (null != channelAndGame && !TextUtils.isEmpty(phone)) {
			channelAndGame.setPhoneNumber(phone);
		}
	}

	public boolean isUpdatePwd() {
		return isUpdatePwd;
	}

	public void setUpdatePwd(boolean isUpdatePwd) {
		this.isUpdatePwd = isUpdatePwd;
	}
	
	public String getUserId(){
		if (null == channelAndGame) {
			return "";
		}
		return channelAndGame.getUserId();
	}

	public void clearUserLoginInfo(Context context){
		if(TextUtils.isEmpty(PersonalCenterModel.getInstance().getUserId())) {
			ToastUtil.show(context,"用户未登录");
			return;
		}
		offLine(context);
		ToastUtil.show(context,"已退出登录");

	}

	/**
	 * 下线
	 * @param context
	 */
	public void offLine(Context context)
	{
		MCApiFactory.getMCApi().offLineAnnounce(context);
		channelAndGame = new ChannelAndGameinfo();
//		FlagControl.isLogin=false;
	}
}
